﻿using System;
using System.IO.Ports;

namespace SoCGadget.Robotics.XBee
{
    public interface IXBeeModule
    {
        event EventHandler<DataSampleReceivedArgs> DataSampleReceived;
        event SerialErrorReceivedEventHandler SerialPortErrorReceived;

        #region Serial Port State

        string SerialPortName { get; }
        bool SerialPortIsOpen { get; }
        void Open();
        void Close();

        #endregion

        #region Send AT Command

        byte SendCommand(string command, Action<CommandStatus> callback);
        byte SendCommand(string command, byte value, Action<CommandStatus> callback);
        byte SendCommand(string command, ushort value, Action<CommandStatus> callback);
        byte SendCommand(string command, uint value, Action<CommandStatus> callback);
        byte SendCommand(string command, string value, Action<CommandStatus> callback);

        #endregion

        #region Send RF Payload

        byte SendString(ulong destinationSerialNumber, ushort destinationAddress, string message, Action<CommandStatus> callback);
        byte SendData(ulong destinationSerialNumber, ushort destinationAddress, byte[] data, Action<CommandStatus> callback);
        byte SendRemoteCommand(ulong destinationSerialNumber, ushort destinationAddress, string command, byte value, Action<CommandStatus> callback);
        byte SendRemoteCommand(ulong destinationSerialNumber, ushort destinationAddress, string command, ushort value, Action<CommandStatus> callback);
        byte SendRemoteCommand(ulong destinationSerialNumber, ushort destinationAddress, string command, uint value, Action<CommandStatus> callback);

        #endregion
    }
}
